package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
@RefreshScope // 使用该注解的类，会在接到SpringCloud配置中心配置刷新的时候，自动将新的配置更新到该类对应的字段中
public class SmsController {
	
	@Value("${sms.suffix}")
	private String smsSuffix;
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@RequestMapping("/send")
	public String sendSms(String content){
		String c = "[" + content+"]" + smsSuffix;
		//jdbcTemplate.execute("insert into sms values('" + c+"')");
		System.out.println(c);
		return c;
	}
}
